package com.mm.util;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * 获取请求头的token值
 * 
 * @ClassName: GetHeadTokenUtil.java
 *
 * @version: v1.0.0
 * @author: 杨朝湖
 * @date: 2019年6月18日 上午11:52:43
 */
public class GetHeadUtil {
	/**
	 * 获取头部的token信息
	 * 
	 * @return 返回token
	 */
	public static String getHeadToken() {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		HttpServletRequest request = attributes.getRequest();
		/* AesEncryptUtils.decrypt */
		String token = request.getHeader("token");
		if (token == "" || token == null) {
			return null;
		}
		return token;
	}

	/**
	 * 获取头部的type
	 * 
	 * @return
	 */
	public static String getHeadType() {
		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
		HttpServletRequest request = attributes.getRequest();
		String type = request.getHeader("type");
		return type;
	}
}
